-- ------------------------------------------------------------------------------------------------
-- Injuries Table Create Script
-- ------------------------------------------------------------------------------------------------
SET NOCOUNT OFF
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
SET ARITHABORT ON
SET CONCAT_NULL_YIELDS_NULL ON
SET QUOTED_IDENTIFIER ON
SET NUMERIC_ROUNDABORT OFF
GO

PRINT 'Creating Table dbo.Injuries...'
GO

IF OBJECT_ID('dbo.Injuries', 'U') IS NULL
BEGIN
	CREATE TABLE dbo.Injuries
	(OID						bigint		IDENTITY(1, 1)	NOT NULL
	,Version					rowversion
	,CaseID						bigint						NOT NULL
	,InjuryID					bigint						NOT NULL
	,InjuryDate					datetime						NULL
	,UpdatedDate				datetime					NOT NULL
		CONSTRAINT DFLT_Injuries_UpdatedDate DEFAULT GETDATE()
	,CreatedDate				datetime					NOT NULL
		CONSTRAINT DFLT_Injuries_CreatedDate DEFAULT GETDATE()

	,CONSTRAINT PK_Injuries PRIMARY KEY CLUSTERED( OID ) --ON PRIMARY

	,CONSTRAINT FK_Injuries_Cases FOREIGN KEY (CaseID)
		REFERENCES Cases(OID)

	,CONSTRAINT FK_Injuries_TypesOfInjury FOREIGN KEY (InjuryID)
		REFERENCES TypesOfInjury(OID)

	)

	PRINT 'Table dbo.Injuries has been created successfully.'

END
ELSE 
BEGIN
    PRINT 'Table dbo.Injuries already exists.'
END

GO
